import storage from '@/utils/storage'
import constant from '@/utils/constant'

const global = {
	state: {
		housing: storage.get(constant.currentHousing)
	},

	mutations: {
		SET_HOUSING: (state, housing) => {
			state.housing = housing
			storage.set(constant.currentHousing, housing)
		},
	},

	actions: {
		// 设置当前小区
		SetCurrentHousing({
			commit
		}, housingInfo) {
			return new Promise((resolve, reject) => {
				commit('SET_HOUSING', housingInfo)
				resolve()
			})
		},
	}
}

export default global